package hfjava;

import java.util.Arrays;
import java.util.Scanner;

public class Fruit_6 {
    public static void main(String[] args) {
        Scanner input =new Scanner(System.in);

        String[] arrs=new String[5];
        char[] arrs1=new char[5];
        for (int i = 0; i <arrs.length ; i++) {
            System.out.println("请输入"+i+"个水果的英文名");
            arrs[i]=input.next();
        }
        for (int i = 0; i <arrs1.length ; i++) {
            System.out.println("请输入"+(i+1)+"个水果的英文名首字母");
            arrs1[i]=input.next().charAt(0);
        }

        for (int i = 0; i < arrs1.length-1; i++) {
            for (int j = 0; j <arrs1.length-1-i ; j++) {
                if (arrs1[j]>arrs1[j+1]){
                    char temp=arrs1[j];
                    arrs1[j]=arrs1[j+1];
                    arrs1[j+1]=temp;
                }
            }
        }
        System.out.println(Arrays.toString(arrs1));
        System.out.println("这些水果的英文名在字典中出现的顺序为");
        for (char fruit : arrs1) {
            switch(fruit){
                case 'a':
                    System.out.println("apple");
                    break;
                case 'b':
                    System.out.println("banana");
                    break;
                case 'g':
                    System.out.println("granp");
                    break;
                case '0':
                    System.out.println("orange");
                    break;
                default:
                    System.out.println("peach");
                    break;
            }
        }
    }
}
